package com.dongxing.concyrrency.chapter3;

import java.util.Arrays;
import java.util.concurrent.TimeUnit;

/**
 * @author XavierDong
 **/
public class CreateThread2 {


//    private static int num = 0x81;

    public static void main(String[] args) {

//        System.out.println(num);
//        System.out.println(num<<1);

        Thread thread = new Thread() {
            @Override
            public void run() {
                try {
                    TimeUnit.SECONDS.sleep(3);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    Thread.currentThread().interrupt();
                }
            }
        };
        thread.start();
//        System.out.println(thread.getThreadGroup());
//        System.out.println(Thread.currentThread().getName());
//        System.out.println(Thread.currentThread().getThreadGroup().getName());

        ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
        System.out.println(threadGroup.activeCount());

        Thread[] threads = new Thread[threadGroup.activeCount()];
        threadGroup.enumerate(threads);
        Arrays.asList(threads).forEach(System.out::println);

    }
}
